package net.xiduth.game.player.content;

import net.xiduth.game.Animation;
import net.xiduth.game.player.Player;
import net.xiduth.utils.Utils;

public class CrystalChest {

	public static final int[] KEY_HALVES = { 985, 987 };
	public static final int KEY = 989;
	public static final int Animation = 881;
	public static int[] amountOfDust = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50};
	public static void makeKey(Player player) {
		if (player.getInventory().containsItem(toothHalf(), 1)
				&& player.getInventory().containsItem(loopHalf(), 1)) {
			player.getInventory().deleteItem(toothHalf(), 1);
			player.getInventory().deleteItem(loopHalf(), 1);
			player.getInventory().addItem(KEY, 1);
			player.getPackets().sendGameMessage(
					"You succesfully make a crystal key.");
		}
	}

	public static void openChest(Player player) {
		if (!player.getInventory().containsItem(989, 1)) {
			player.getPackets()
					.sendGameMessage("The chest is securely locked.");
			return;
		} else if (player.getInventory().containsItem(989, 1)) {
			player.getInventory().deleteItem(989, 1);
			player.setNextAnimation(new Animation(881));
			player.getPackets().sendGameMessage(
					"You unlock the chest with your key.");
			player.getInventory().addItem(995, Utils.random(1, 100000));
			player.getInventory().addItem(405, 1);
			player.getInventory().addItem(13727, Utils.random(35));
			player.getInventory().refresh();
		}
	}

	public static int toothHalf() {
		return KEY_HALVES[0];
	}

	public static int loopHalf() {
		return KEY_HALVES[1];
	}
}